package day240918;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/RequestServlet2")
public class RequestServlet2 extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();

        // 打印 request 信息
        out.println("Request 信息:");
        out.println("Request URL: " + request.getRequestURL());
        out.println("Request URI: " + request.getRequestURI());
        out.println("方法: " + request.getMethod());

        // 打印 response 信息
        out.println("Response 信息:");
        out.println("状态: " + response.getStatus());
        out.println("内容类型: " + response.getContentType());
    }
}

